/*
 * Copyright 2011 Subhabrata Ghosh <subho.ghosh at langene.net>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



package net.langene.nlp.model;

//~--- JDK imports ------------------------------------------------------------

import java.util.LinkedList;
import java.util.List;

//~--- classes ----------------------------------------------------------------

/**
 *
 * @author Subhabrata Ghosh <subho.ghosh at langene.net>
 */
public class Sentence {
    private int		endOffset;
    private String	sentence;
    private int		startOffset;
    private List<Token>	tokens;

    //~--- constructors -------------------------------------------------------

    /**
     * Create a new Sentence Object.
     *
     * @param sentence
     */
    public Sentence(String sentence) {
        this.sentence = sentence;
    }

    //~--- get methods --------------------------------------------------------

    /**
     * @return the sentence
     */
    public String getSentence() {
        return sentence;
    }

    /**
     * @return the tokens
     */
    public List<Token> getTokens() {
        return tokens;
    }

    //~--- set methods --------------------------------------------------------

    /**
     * @param tokens the tokens to set
     */
    public void setTokens(List<Token> tokens) {
        this.tokens = tokens;
    }

    //~--- methods ------------------------------------------------------------

    /**
     * Add a token to the Sentence.
     *
     * @param token
     */
    public void addToken(Token token) {
        if (this.tokens == null) {
            this.tokens = new LinkedList<Token>();
        }

        this.tokens.add(token);
    }

    //~--- get methods --------------------------------------------------------

    /**
     * @return the startOffset
     */
    public int getStartOffset() {
        return startOffset;
    }

    //~--- set methods --------------------------------------------------------

    /**
     * @param startOffset the startOffset to set
     */
    public void setStartOffset(int startOffset) {
        this.startOffset = startOffset;
    }

    //~--- get methods --------------------------------------------------------

    /**
     * @return the endOffset
     */
    public int getEndOffset() {
        return endOffset;
    }

    //~--- set methods --------------------------------------------------------

    /**
     * @param endOffset the endOffset to set
     */
    public void setEndOffset(int endOffset) {
        this.endOffset = endOffset;
    }

    //~--- methods ------------------------------------------------------------

    @Override
    public String toString() {
        StringBuilder	buff = new StringBuilder();

        buff.append(getSentence());

        if ((tokens != null) && (tokens.size() > 0)) {
            for (Token tk : tokens) {
                buff.append("\n\t").append(tk.toString());
            }
        }

        return buff.toString();
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
